<?php
/**
 * 控制器基础类，所有控制器均需继承此类
 * @author chenfenghua <843958575@qq.com>
 * version v2.0
 */

namespace app\api\components;

use app\models\member\MemberAccount;
use Yii;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\Response;

class ApiController extends Controller
{
    public static $CODE_SUC = "200";
    public static $CODE_ERR = "400";
    const LIMIT = 10;
    public $data = [];

    private $_user_id;

    public function init()
    {
        parent::init(); // TODO: Change the autogenerated stub

        Yii::$app->response->format = Response::FORMAT_JSON;
    }
    

    //获取当前用户ID
    public function getUserId()
    {
        return $this->_user_id;
    }

    /**
     * 返回json消息
     *
     * @param $message
     * @param string $code
     * @return array
     */
    public static function sendMessageJson($message, $code = '',$data=[])
    {
        $code = empty($code) ? self::$CODE_ERR : $code;
        return ['code' => $code, 'msg' => $message, 'data' => $data];
    }


}